package com.ruoyi.web.controller.pos;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.oper.domain.OperChima;
import com.ruoyi.oper.domain.OperProduct;
import com.ruoyi.oper.domain.OperProitems;
import com.ruoyi.oper.domain.OperYanse;
import com.ruoyi.oper.service.IOperProductService;
import com.ruoyi.pos.domain.PosColour;
import com.ruoyi.pos.domain.PosShangpin;
import com.ruoyi.pos.domain.PosShangpinItem;
import com.ruoyi.pos.domain.PosSize;
import com.ruoyi.pos.service.IPosShangpinService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

@RestController
@RequestMapping("/pos/pos_shangpin")
public class PosShangpinController extends BaseController {

    @Autowired
    private IPosShangpinService posShangpinService;

    @GetMapping("/list")
    public TableDataInfo list(PosShangpin posShangpin){
        startPage();
        List<PosShangpin> list = posShangpinService.selectPosShangpinList(posShangpin);
        return getDataTable(list);
    }
    @GetMapping("/all_shangpin")
    public Map<String,List<PosShangpin>> getPosShangpin(PosShangpin posShangpin){
        posShangpin.setCid(1);
        List<PosShangpin> woman = posShangpinService.selectPosShangpinList(posShangpin);
        posShangpin.setCid(2);
        List<PosShangpin> man = posShangpinService.selectPosShangpinList(posShangpin);
        posShangpin.setCid(3);
        List<PosShangpin> manShoes = posShangpinService.selectPosShangpinList(posShangpin);
        posShangpin.setCid(4);
        List<PosShangpin> womanShoes = posShangpinService.selectPosShangpinList(posShangpin);
        Map<String,List<PosShangpin>> map = new HashMap<>();
        map.put("woman",woman);
        map.put("man",man);
        map.put("manShoes",manShoes);
        map.put("womanShoes",womanShoes);
        return map;
    }
    @GetMapping("/detail")
    public PosShangpin detail(Integer shangpinId){
        PosShangpin posShangpin = posShangpinService.selectPosShangpinById(shangpinId);
        List<PosColour> posColourList = posShangpinService.selectPosColourList(shangpinId);
        posShangpin.setPosColourList(posColourList);
        return posShangpin;
    }
    @GetMapping("/get_size")
    public List<PosSize> getSize(PosShangpinItem posShangpinItem){
        return posShangpinService.selectPosSizeList(posShangpinItem);
    }
}
